#!/usr/bin/env python3

import transformers
import sys
import os

model_name = os.environ["MODEL_NAME"]
tokenizer = transformers.MarianTokenizer.from_pretrained(model_name)
input_path = sys.argv[1]
output_path = sys.argv[2]

with tokenizer.as_target_tokenizer():
    with open(input_path) as input_file, open(output_path, "w") as output_file:
        for line in input_file:
            text = tokenizer.decode(list(map(int, line.strip().split())))
            output_file.write(text)
            output_file.write("\n")
